package cn.meibang.common.beauty.provider.dao;

import cn.apestar.core.database.BaseMapper;
import cn.meibang.common.beauty.provider.domain.BeautyConsultationOrder;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface BeautyConsultationOrderMapper extends BaseMapper {
    @Delete({
            "delete from beauty_consultation_order",
            "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
            "insert into beauty_consultation_order (id, user_id, ",
            "type, status, start_date, ",
            "end_date, create_by, create_date, ",
            "update_by, update_date, ",
            "remarks, del_flag, institution_id)",
            "values (#{id,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, ",
            "#{type,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{startDate,jdbcType=DATE}, ",
            "#{endDate,jdbcType=DATE}, #{createBy,jdbcType=BIGINT}, #{createDate,jdbcType=TIMESTAMP}, ",
            "#{updateBy,jdbcType=BIGINT}, #{updateDate,jdbcType=TIMESTAMP}, ",
            "#{remarks,jdbcType=VARCHAR}, #{delFlag,jdbcType=CHAR}, #{institutionId,jdbcType=BIGINT})"
    })
    int insert(BeautyConsultationOrder record);

    @InsertProvider(type = BeautyConsultationOrderSqlProvider.class, method = "insertSelective")
    int insertSelective(BeautyConsultationOrder record);

    @Select({
            "select",
            "id, user_id, type, status, start_date, end_date, create_by, create_date, update_by, ",
            "update_date, remarks, del_flag, institution_id",
            "from beauty_consultation_order",
            "where id = #{id,jdbcType=BIGINT} and del_flag = '1'"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "user_id", property = "userId", jdbcType = JdbcType.BIGINT),
            @Result(column = "type", property = "type", jdbcType = JdbcType.VARCHAR),
            @Result(column = "status", property = "status", jdbcType = JdbcType.VARCHAR),
            @Result(column = "start_date", property = "startDate", jdbcType = JdbcType.DATE),
            @Result(column = "end_date", property = "endDate", jdbcType = JdbcType.DATE),
            @Result(column = "create_by", property = "createBy", jdbcType = JdbcType.BIGINT),
            @Result(column = "create_date", property = "createDate", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "update_by", property = "updateBy", jdbcType = JdbcType.BIGINT),
            @Result(column = "update_date", property = "updateDate", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "remarks", property = "remarks", jdbcType = JdbcType.VARCHAR),
            @Result(column = "del_flag", property = "delFlag", jdbcType = JdbcType.CHAR),
            @Result(column = "institution_id", property = "institutionId", jdbcType = JdbcType.BIGINT)
    })
    BeautyConsultationOrder selectByPrimaryKey(Long id);

    @Select({
            "select",
            "id, user_id, type, status, start_date, end_date, create_by, create_date, update_by, ",
            "update_date, remarks, del_flag, institution_id",
            "from beauty_consultation_order",
            "where status = '1' and del_flag = '1'"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "user_id", property = "userId", jdbcType = JdbcType.BIGINT),
            @Result(column = "type", property = "type", jdbcType = JdbcType.VARCHAR),
            @Result(column = "status", property = "status", jdbcType = JdbcType.VARCHAR),
            @Result(column = "start_date", property = "startDate", jdbcType = JdbcType.DATE),
            @Result(column = "end_date", property = "endDate", jdbcType = JdbcType.DATE),
            @Result(column = "create_by", property = "createBy", jdbcType = JdbcType.BIGINT),
            @Result(column = "create_date", property = "createDate", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "update_by", property = "updateBy", jdbcType = JdbcType.BIGINT),
            @Result(column = "update_date", property = "updateDate", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "remarks", property = "remarks", jdbcType = JdbcType.VARCHAR),
            @Result(column = "del_flag", property = "delFlag", jdbcType = JdbcType.CHAR),
            @Result(column = "institution_id", property = "institutionId", jdbcType = JdbcType.BIGINT)
    })
    List<BeautyConsultationOrder> selectValidOrder();

    @UpdateProvider(type = BeautyConsultationOrderSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(BeautyConsultationOrder record);

    @Update({
            "update beauty_consultation_order",
            "set user_id = #{userId,jdbcType=BIGINT},",
            "type = #{type,jdbcType=VARCHAR},",
            "status = #{status,jdbcType=VARCHAR},",
            "start_date = #{startDate,jdbcType=DATE},",
            "end_date = #{endDate,jdbcType=DATE},",
            "create_by = #{createBy,jdbcType=BIGINT},",
            "create_date = #{createDate,jdbcType=TIMESTAMP},",
            "update_by = #{updateBy,jdbcType=BIGINT},",
            "update_date = #{updateDate,jdbcType=TIMESTAMP},",
            "remarks = #{remarks,jdbcType=VARCHAR},",
            "del_flag = #{delFlag,jdbcType=CHAR},",
            "institution_id = #{institutionId,jdbcType=BIGINT}",
            "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(BeautyConsultationOrder record);
}